Public Class Query
    Inherits System.Web.UI.Page
    Protected WithEvents DG_CUST As System.Web.UI.WebControls.DataGrid
    Protected WithEvents Label3 As System.Web.UI.WebControls.Label
    Protected WithEvents lbl_user As System.Web.UI.WebControls.Label
    Protected WithEvents Lbl_date As System.Web.UI.WebControls.Label
    Protected WithEvents Label6 As System.Web.UI.WebControls.Label
    Protected WithEvents lbl_stat As System.Web.UI.WebControls.Label
    Protected WithEvents lbl_tar As System.Web.UI.WebControls.Label
    Protected WithEvents btn_ara As System.Web.UI.WebControls.Button
    Protected WithEvents ddl_stat As System.Web.UI.WebControls.DropDownList
    Protected WithEvents txt_date As System.Web.UI.WebControls.TextBox
    Protected WithEvents Lblok As System.Web.UI.WebControls.Label
    Protected WithEvents HyperLink1 As System.Web.UI.WebControls.HyperLink
    Protected WithEvents Image1 As System.Web.UI.WebControls.Image
    Protected WithEvents Image2 As System.Web.UI.WebControls.Image
    Protected WithEvents HyperLink2 As System.Web.UI.WebControls.HyperLink

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        'Put user code to initialize the page here
        Dim SQL As String

        Dim usr As String
        Dim ds As New myDBConn()
        Session.LCID = 1055

        If Page.IsPostBack Then Exit Sub
        Me.Lbl_date.Text = Now.ToShortDateString
        usr = Request.ServerVariables("LOGON_USER")
        SQL = "SELECT a.name FROM USERS a,perms p WHERE  a.usrid=p.usrid and a.LOGUSR= '" & usr & "' and appid=1;"

        If ds.myOleDbTable(SQL).Rows.Count > 0 Then
            Me.lbl_user.Text = ds.myOleDbTable(SQL).Rows(0)(0)
        Else
            Response.Redirect("logout.htm")
        End If


        ds = Nothing
    End Sub

    Public Sub search()
        Dim sql1 As String
        Dim ds As New myDBConn()

        sql1 = " select entry_id,custcode,company_name,copy_count,entry_date,entry_user"
        sql1 = sql1 & " from it_copy_la_customer where copy_status like '" & Me.ddl_stat.SelectedItem.Value & "' "
        If Not Trim(Me.txt_date.Text) = "" Then
            sql1 = sql1 & " and trunc(entry_date)='" & Me.txt_date.Text & "'"
        End If
        sql1 = sql1 & " order by entry_id"
        If ds.myORATable(sql1).Rows.Count > 0 Then
            Me.DG_CUST.DataSource = ds.myORATable(sql1)
            Me.DG_CUST.DataBind()
            'If Me.ddl_stat.SelectedItem.Value <> "0" Then
            '    DG_CUST.Columns(0).Visible = False
            'Else
            '    DG_CUST.Columns(0).Visible = True
            'End If
            Me.DG_CUST.Visible = True
            Me.Lblok.Visible = False
        Else
            Me.DG_CUST.Visible = False
            Me.Lblok.Visible = True
            Me.Lblok.Text = "No data found"

        End If
        ds = Nothing

    End Sub


    Private Sub btn_ara_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ara.Click
        Me.DG_CUST.CurrentPageIndex = 0
        search()
    End Sub

    'Private Sub dg_cust_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DG_CUST.EditCommand
    '    Dim sql As String
    '    Dim ds As New myDBConn()

    '    sql = "update it_copy_la_customer set copy_details='Cancelled',copy_status=3 where entry_id=" & e.Item.Cells(1).Text & ""
    '    ds.ORAExecute(sql)
    '    ds = Nothing
    '    search()
    'End Sub

    'Private Sub txt_date_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_date.TextChanged
    '    If Not IsDate(Me.txt_date.Text) Then
    '        Response.Write("<SCRIPT language=""JavaScript"">" & vbCrLf & "{" & vbCrLf)
    '        Response.Write("alert(""Enter a valid date !!"")" & vbCrLf)
    '        Response.Write("}" & vbCrLf & "</SCRIPT>" & vbCrLf)
    '        Exit Sub
    '    End If
    'End Sub

    Private Sub DG_CUST_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DG_CUST.SelectedIndexChanged

    End Sub

    Private Sub DG_CUST_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DG_CUST.PageIndexChanged
        Me.DG_CUST.CurrentPageIndex = e.NewPageIndex
        search()
    End Sub
End Class
